/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

export const ARKOALA_PACKAGE = 'org.koalaui.arkoala'
export const INTEROP_PACKAGE = 'org.koalaui.interop'

export const ARKOALA_PACKAGE_PATH = getPackagePath(ARKOALA_PACKAGE)
export const INTEROP_PACKAGE_PATH = getPackagePath(INTEROP_PACKAGE)

export const ARK_OBJECTBASE = 'Ark_ObjectBase'
export const ARK_BASE = 'ArkBase'
export const ARK_UI_NODE_TYPE = 'ArkUINodeType'
export const ARK_MATERIALIZEDBASE = 'Ark_MaterializedBase'
export const ARK_CUSTOM_OBJECT = 'Ark_CustomObject'
export const ARK_MATERIALIZEDBASE_EMPTY_PARAMETER = `${ARK_MATERIALIZEDBASE}.EmptyParameter`
export const INT_VALUE_GETTER = 'IntValueGetter'
export const COMPONENT_BASE = 'ComponentBase'

function getPackagePath(javaPackage: string): string {
    return javaPackage.replaceAll('.', '/')
}

export function convertJavaOptional(type: string): string {
    switch (type) {
        case 'boolean': return  'Opt_Boolean'
        case 'double': return 'Opt_Number'
    }
    return type
}

export const javaCustomTypeMapping = new Map<string, string>([
    ['Dimension', 'Ark_Length'],
    ['Length', 'Ark_Length'],
    ['ContentModifier', ARK_CUSTOM_OBJECT],
    ['Optional', 'Optional'],
])
